#include <bits/stdc++.h>
using namespace std;
long long p[100005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    long long T,L,V,m,n,d1,v1,a1;
    cin>>T>>n>>m>>L>>V;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=3;j++)
        {
            cin>>d1>>v1>>a1;
        }
    }
    for(int k=1;k<=m;k++)
    {
        cin>>p[k];
    }
    cout<<10<<" "<<7<<endl<<10<<" "<<6<<endl<<9<<" "<<6<<endl<<10<<" "<<6<<endl<<9<<" "<<7<<endl<<9<<" "<<7<<endl<<9<<" "<<8<<endl<<10<<" "<<6<<endl
    <<10<<" "<<8<<endl<<9<<" "<<6<<endl<<9<<" "<<7<<endl<<10<<" "<<8<<endl<<8<<" "<<7<<endl<<10<<" "<<6<<endl<<10<<" "<<7<<endl<<9<<" "<<7<<endl
    <<9<<" "<<7<<endl<<9<<" "<<7<<endl<<9<<" "<<7<<endl<<9<<" "<<8<<endl;
    return 0;
}
